package com.ldzy.configuration;

import com.ldzy.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    //这样通过实现接口来注册拦截器，只需要排除放行静态资源的请求地址，就不会拦截resources/static下面的静态资源
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/toLoginPage","/login","/image/**","/css/**","/js/**","/font/**");
    }
}
